/**
 * Created by Administrator on 2019/1/12 0012.
 */
// 发送信息
function SendMsg(text) {
    if (text == "" || text == null) {
        alert("发送信息为空，请输入！")
    } else {
        AddMsg('default', SendMsgDispose(text));
        document.getElementById("text").value = "";
    }
}

// 发送的信息处理
function SendMsgDispose(detail) {
    detail = detail.replace("\n", "<br>").replace(" ", "&nbsp;")
    return detail;
}

// 增加信息
function AddMsg(user, content) {
    var str = CreadMsg(user, content);
    var msgs = document.getElementById("msgs");
    msgs.innerHTML = msgs.innerHTML + str;
}

// 生成内容
function CreadMsg(user, content) {
    var str = "";
    if (user == 'default') {
        str = "<div class=\"msg guest\"><div class=\"msg-right\"><div class=\"msg-host headDefault\"></div><div class=\"msg-ball\" title=\"今天 17:52:06\">" + content + "</div></div></div>"
    }
    else {
        str = "<div class=\"msg robot\"><div class=\"msg-left\" worker=\"" + user + "\"><div class=\"msg-host photo\" style=\"background-image: url(../Images/14761555537.png)\"></div><div class=\"msg-ball\" title=\"今天 17:52:06\">" + content + "</div></div></div>";
    }
    return str;
}